package com.itheima.health.mobile.config;

import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;

import java.util.Arrays;

@Configuration
public class SpringMvcConfiguration {
    /**
     * @Author: 位帅帅
     * @Date: 14:15 2021/1/10
     * @Params: []
     * @RerurnType: org.springframework.boot.autoconfigure.http.HttpMessageConverters
     * @Description: Http Json消息转换器
    */
    @Bean
    public HttpMessageConverters fastJsonHttpMessageConverters() {
        //定义消息转换对象
        FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
        //指定需要转换的数据类型
        fastConverter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8));
        //返回
        return new HttpMessageConverters(fastConverter);
    }
}
